package com.ctshk.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.List;

/**
 * @author 谢诗宏
 * @description 审批流程类型
 * @date 2021/3/11
 */
@AllArgsConstructor
public enum ApprovalBusinessMapper {

    /**
     * 资源中心 - 1到100
     */
    // 新增產品
    RESOURCE_ADD_PRODUCT(1, "资源中心-新增產品審批", Arrays.asList(SystemBusinessType.FIXED_PACKAGE_TICKET, SystemBusinessType.HOTEL,
            SystemBusinessType.AIR_TICKET, SystemBusinessType.TRAIN_TICKET, SystemBusinessType.SHIP_TICKET, SystemBusinessType.BUS_TICKET,
            SystemBusinessType.AIR_EXPRESS, SystemBusinessType.ATTRACTION_TICKET, SystemBusinessType.LOCAL_FUN, SystemBusinessType.VISA,
            SystemBusinessType.CERTIFICATE_HANDLE, SystemBusinessType.COMMODITY), false, false),

    /**
     * 产品中心 - 101到200
     */
    PRODUCT_TRIP(2, "行程管理-行程审批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.INBOUND_TRAVEL), false, false),
    PRODUCT_FINISH_GROUP_TOUR(3, "旅行團管理-完團審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.INBOUND_TRAVEL), false, false),
    PRODUCT_FINISH_GROUP_CUSTOM(4, "團期管理-完團審批", Arrays.asList(SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, false),

    /**
     * 预订中心 - 201到300
     */
    BOOKING_CHASE_SEAT(5, "旅行團-追位審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.INBOUND_TRAVEL), true, false),
    BOOKING_DISCOUNT(6, "訂單操作-折扣審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), true, false),
    BOOKING_REFUND(7, "訂單操作-退款審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), true, false),
    BOOKING_LEAVE_GROUP(8, "訂單操作-退團審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), true, false),

    /**
     * 订单中心 - 301到400
     */
    ORDER_CANCEL_ORDER(9, "操作訂單-取消訂單審批", Arrays.asList(SystemBusinessType.FIXED_PACKAGE_TICKET, SystemBusinessType.HOTEL,
            SystemBusinessType.AIR_TICKET, SystemBusinessType.TRAIN_TICKET, SystemBusinessType.SHIP_TICKET, SystemBusinessType.BUS_TICKET,
            SystemBusinessType.AIR_EXPRESS, SystemBusinessType.ATTRACTION_TICKET, SystemBusinessType.LOCAL_FUN, SystemBusinessType.VISA,
            SystemBusinessType.CERTIFICATE_HANDLE, SystemBusinessType.COMMODITY), true, false),

    /**
     * 运营中心 - 401到500
     */
    IOTC_ADD_PROMOTION_CODE(10, "推广码-新增推廣碼審批", Arrays.asList(SystemBusinessType.IOTC), false, false),
    IOTC_ADD_BANK_DISCOUNT(11, "推广码-新增銀行優惠審批", Arrays.asList(SystemBusinessType.IOTC), false, false),
    /**
     * 财务中心 - 501到600
     */
    // 申請預收款
    FINANCE_APPLY_ADVANCE_PAYMENT(12, "预收管理-申請預收款審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    // 申请预退收
    FINANCE_APPLY_ADVANCE_REFUND(13, "申请退预收-申請退預收審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    // 认款
    FINANCE_RECOGNITION(14, "认款管理-認款審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    // 客户对账
    FINANCE_CUSTOMER_RECONCILIATION(15, "客户对账-客戶對賬審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    FINANCE_APPLY_OPEN_ACCOUNT_AGENT(16, "大客户/代理商-申請掛賬審批", Arrays.asList(SystemBusinessType.FINANCE), false, true),
    FINANCE_APPLY_WRITE_OFF_AGENT(17, "大客户/代理商-申請銷賬審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    FINANCE_APPLY_OPEN_ACCOUNT_INTERNAL(18, "内部挂账-申請掛賬審批", Arrays.asList(SystemBusinessType.FINANCE), false, true),
    FINANCE_APPLY_WRITE_OFF_INTERNAL(19, "内部挂账-申請销账審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    FINANCE_APPLY_WRITE_OFF_GROUP(20, "集团客户-申请销账审批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    FINANCE_APPLY_SPECIAL_COLLECTION(21, "特殊收款管理-申請特殊收款審批", Arrays.asList(SystemBusinessType.FINANCE), false, true),
    FINANCE_APPLY_PREPAYMENT(22, "预付管理-申請預付審批", Arrays.asList(SystemBusinessType.FINANCE), false, true),
    FINANCE_APPLY_SUPPLIER_RECONCILIATION(23, "供应商对账-申請供應商對賬審批", Arrays.asList(SystemBusinessType.FINANCE), false, false),
    FINANCE_APPLY_ACTUAL_PAYMENT(24, "供应商实付-申請實付審批", Arrays.asList(SystemBusinessType.FINANCE), false, true),

    /**
     * 供应商预订 - 601到700
     */
    SUPPLIER_BOOKING_ADD_AIR_BOOKING(25, "新增機票預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_TRAIN_BOOKING(26, "新增火車票預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_SHIP_BOOKING(27, "新增船票預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_CAR_RENTAL_BOOKING(28, "新增租車預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_FOOD_BOOKING(29, "新增餐飲預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_HOTEL_BOOKING(30, "新增酒店預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_GRI_BOOKING(31, "新增綜費預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),
    SUPPLIER_BOOKING_ADD_SCENIC_BOOKING(32, "新增門票預訂審批", Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL, SystemBusinessType.OUTBOUND_CUSTOMIZATION, SystemBusinessType.INBOUND_TRAVEL, SystemBusinessType.INBOUND_CUSTOMIZATION, SystemBusinessType.CONFERENCE_AWARDS), false, true),

    /**
     * 系統管理 - 701到800
     */
    RESOURCES_ADD_SUPPLIER(33, "供应商管理-新增供應商", Arrays.asList(SystemBusinessType.RESOURCES), false, false),
    RESOURCES_ADD_AGENT(34, "代理商管理-新增代理商", Arrays.asList(SystemBusinessType.RESOURCES), false, false),
    RESOURCES_ADD_BIG_CLIENT(35, "大客户管理-新增大客戶", Arrays.asList(SystemBusinessType.RESOURCES), false, false),
    ;

    @Getter
    @Setter
    private int code;

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private List<SystemBusinessType> businessTypeList;

    // 是否动态审批
    @Getter
    @Setter
    private boolean isDynamic;

    // 是否条件审批
    @Getter
    @Setter
    private boolean isCondition;

    public static String parseValue(int code) {
        for (ApprovalBusinessMapper type : ApprovalBusinessMapper.values()) {
            if (type.code == code) {
                return type.getValue();
            }
        }
        return null;
    }
}
